import { ref, onMounted, onBeforeUnmount } from "vue";
export default function () {
  const x = ref(-1);
  const y = ref(-1);

  // 点击事件的回调函数
  const clickHandler = (event: any) => {
    x.value = event.pageX;
    y.value = event.pageY;
  };
  onMounted(() => {
    window.addEventListener("click", clickHandler);
  });
  // 页面卸载qian
  onBeforeUnmount(() => {
    window.removeEventListener("click", clickHandler);
  });
  return { x, y };
}
